package com.msite.util

import com.msite.util.encrypt.HMAC

import java.security.SecureRandom

/**
 * Created by tpeng on 2015/11/27.
 */
class MUtils {

    /**
     * 用户密码加密
     * @param data
     * @return
     */
    static String encryptPassword(String salt, String data){
        HMAC.encryptHMAC(salt, data)
    }

    /**
     * 生成用户密码salt
     * @param numBytes
     * @return
     */
    static String encryptSalt(int numBytes){
        byte[] bytes = new byte[numBytes];
        new SecureRandom().nextBytes(bytes);
        HMAC.encryptBase64(bytes)
    }

    public static void main(String[] args) {
        def salt = encryptSalt(5);
        println salt
        def a = MUtils.encryptPassword(salt, "wwwwww");
        println a
    }
}
